using System.Collections.Generic;

namespace AzManContrib.MVC.Html.Behaviors
{
    public abstract class UIBehaviorBase : IUIBehavior
    {
        public abstract bool ShouldRender { get; }
        
        public abstract IDictionary<string, object> GetHtmlAttributes(IDictionary<string, object> attributes);

        public IDictionary<string, object> MergeHtmlAttributes(IDictionary<string, object> attributes, string attributeName, string separator, string attributeValue)
        {
            object attr;
            if (attributes.TryGetValue(attributeName, out attr) == false)
                attr = "";

            attributes[attributeName] = attr + string.Format("{1}{0}{1}", attributeValue, separator);
            
            return attributes;
        }
    }
}